#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int n,g1,g2;
struct Stu{
    string name,id;
    int grade;
};
vector<Stu> v;

int cmp(Stu &s1,Stu &s2){
    return s1.grade>s2.grade;
}

signed main()
{
    cin>>n;
    v.resize(n);
    for(int i=0;i<n;i++)    cin>>v[i].name>>v[i].id>>v[i].grade;
    cin>>g1>>g2;
    sort(v.begin(),v.end(),cmp);
    int flag = 0;
    for(int i=0;i<v.size();i++){
        if(v[i].grade>=g1&&v[i].grade<=g2){
            cout<<v[i].name<<" "<<v[i].id<<"\n";
            flag = 1;
        }
    }
    if(!flag)    cout<<"NONE\n";
    return 0;
}
